home *** CD-ROM | disk | FTP | other *** search
- /*
- * the class STAGE_MOVE_LINE_CORE
- * Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
- */
-
- #include "../stdafx.h"
-
- #include "../common/bool.h"
-
- #include "stmvline.h"
-
- void STAGE_MOVE_LINE_CORE::erase_selected_line(KBAN_DRAW& draw)
- {
- draw.erase_primitive_line(*m_target);
- }
-
- void STAGE_MOVE_LINE_CORE::redraw_selected_line(KBAN_DRAW& draw)
- {
- draw.draw_primitive_line(*m_target, m_old_active_layer);
- }
-
- STAGE_MOVE_LINE_CORE::STAGE_MOVE_LINE_CORE(LINE_ELEMENT* target, uint layer, const XY& ac_base)
- : m_target(target),
- m_old_active_layer(layer),
- m_mcur(*target, ac_base),
- m_ac_base(ac_base),
- m_moved(FALSE)
- {
- }
-
- STAGE_MOVE_LINE_CORE::STAGE_MOVE_LINE_CORE(LINE_ELEMENT* target, uint layer, const XY& ac_base, const XY& pc_old)
- : m_target(target),
- m_old_active_layer(layer),
- m_mcur(*target, ac_base),
- m_ac_base(ac_base),
- m_moved(TRUE),
- m_pc_old(pc_old)
- {
- }
-
- STAGE* STAGE_MOVE_LINE_CORE::init(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- erase_selected_line(draw);
- if(m_moved.get()) {
- mouse_move(info, draw, m_pc_old, 0);
- } else {
- m_mcur.redraw_cursor(draw);
- }
- return this;
- }
-
- STAGE* STAGE_MOVE_LINE_CORE::redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- erase_selected_line(draw);
- m_mcur.redraw_cursor(draw);
- return this;
- }
-
- STAGE* STAGE_MOVE_LINE_CORE::mouse_move(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- m_moved.set(TRUE);
- m_pc_old = pc;
-
- XY ac;
- info.grid().xy_pc2ac_with_snap_off(pc, ac);
-
- XY ac_dif = ac - m_ac_base;
- if(info.grid().snap_get()) {
- info.grid().snap(ac_dif);
- }
-
- m_mcur.draw_cursor(draw, ac_dif);
- return this;
- }
-
- STAGE* STAGE_MOVE_LINE_CORE::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- m_mcur.erase_cursor(draw);
- XY ac;
- info.grid().xy_pc2ac(pc, ac);
-
- XY ac_dif = ac - m_ac_base;
-
- if(info.grid().snap_get()) {
- info.grid().snap(ac_dif);
- }
-
- m_target->set_ac_s(m_target->ac_s() + ac_dif);
- m_target->set_ac_e(m_target->ac_e() + ac_dif);
- draw.draw_primitive_line(*m_target, m_old_active_layer);
- info.SetModifiedFlag();
- info.new_state().set(true);
- info.new_state_str() = "Move Line";
-
- m_done.set(TRUE);
- return NULL;
- }
-
- STAGE* STAGE_MOVE_LINE_CORE::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- return NULL;
- }
-
- void STAGE_MOVE_LINE_CORE::end(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- if(!m_done.get()) {
- m_mcur.erase_cursor(draw);
- redraw_selected_line(draw);
- }
- }
-